/**
 * Created by lil09 on 15-10-15.
 */
define(function (require, exports, module) {
    var $ = require("jquery");
    var angular = require("angular");
    var ui = require("ui");
    require('authorize');
    require("permission");
    require("angular-route");
    require("angular-ui");
    require("angular-interceptor");
    require('../../myservice/common/nav');
    require("./activities-service");
    require("/static_public/js/angular_directive/clipboard");

    var app = angular.module('app', ['ngRoute', 'ngUI', 'ngInterceptor', 'appointmentActivitiesModule', 'myNav', 'angular.directive.clipboard']);

    app.config(['$routeProvider', function ($routeProvider) {
        $routeProvider
            .when('/list', {templateUrl: 'activities/list.html', controller: 'AppointmentActivitiesListController'})
            .otherwise({redirectTo: '/list'});
    }]);
    /**
     * 格式化预约形式
     */
    app.filter('formatYuYue', function () {
        return function (status) {
            var txt = "普通预约";
            if(status==1){
                txt = "专车预约";
            }
            return txt;
        };
    });
    app.controller('AppointmentActivitiesListController', ['$scope', '$routeParams', 'appointmentActivities', function ($scope, $routeParams, appointmentActivities) {
        $scope.filterDataCities = [];
        $scope.filterDataYuYue = [
            {value: '', name: '全部', selected: true},
            {value: '1', name: '专车预约'},
            {value: '0', name: '普通预约'}
        ];

        $scope.currCity = {myscrm_CityId:''};
        $scope.currYuYue = {value:''};

        $scope.activitiesSvr = appointmentActivities;
        $scope.activitiesSvr.getCityList();
        //搜索操作
        $scope.search = function () {
            $scope.activitiesSvr.query($scope.currCity.myscrm_CityId,$scope.currYuYue.value);
        };
        $(document).on('click', function (e) {
            if ($(e.target).is('.showqr')) {
                return;
            }
            $scope.activitiesSvr.showQR = '';
        });
        $scope.aftercopyNotify = function () {
            ui.showSucTip('复制成功');
        }
        $scope.activitiesSvr.query($scope.currCity.myscrm_CityId,$scope.currYuYue.value);
    }]);

    angular.bootstrap(document, ['app']);
});